<?php
include 'index.php';
if (isset($_GET['lang'])){
if ($_GET['lang'] == 'ar'){
    include '../lang/ar.php';
}
}
?>

<div id="body-wrapper">

    <div id="main-content">

        <div class="content-box">

            <?php
            include '../db/db_con.php';
            
            ?>
            <?php
            if (isset($_POST['addproduct'])) {
             if ($_FILES["image"]["name"] != "") {


        if ($_FILES["image"]["type"] == "image/gif" || $_FILES["image"]["type"] == "image/jpeg" || $_FILES["image"]["type"] == "image/jpg" || $_FILES["image"]["type"] == "image/pjpeg") {

            move_uploaded_file($_FILES["image"]["tmp_name"], "img/upload/" . $_FILES["image"]["name"]);

            $img = "img/upload/" . $_FILES["image"]["name"];
        }else{
            echo 'no '.mysql_error();
        }
    }
                $title_ar = $_POST['title_ar'];
                $title_en = $_POST['title_en'];
                $desc_ar = $_POST['desc_ar'];
                $desc_en = $_POST['desc_en'];
                $price = $_POST['price'];
              
                 $type = $_POST['type'];
                   if ($type == 'General'){
                       $type = '1';
                   }else{
                       $type = '0';
                   }
                $status = $_POST['status'];
                $cat = $_POST['cat'];

                $query = "INSERT INTO products (title_ar,title_en,desc_ar,desc_en,image,status,cat,price,type)
                VALUES ('{$title_ar}','{$title_en}','{$desc_ar}','{$desc_en}','{$img}','{$status}',{$cat},{$price},$type)";


                if (mysql_query($query)) {

                    echo '
     <div class="notification success png_bg">
     <a href="" class="close"><img src="resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
	<div>
	     This Product Addes Is Done ..
	</div>
      </div>';
                } else {
                    echo '
        <div class="notification error png_bg">
	<a href="" class="close"><img src="resources/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
	 <div>
	      This Product Addes Is Not Done ..
	 </div>
	</div>';
                }
            }
            ?>

            <div class="content-box-header" id = "addProducts" >

                <h3><?= Add_Product ?></h3>

                <div class="clear"></div>
            </div>
            <div class="content-box-content">

                <div class="tab-content default-tab" id="tab2">

                    <form action="AddProducts.php?type=Product&lang=<?= $lang ?>" method="post" name = "addproduct" enctype="multipart/form-data">

                        <fieldset>
                            <p>
                                <label><?= product_title_ar ?></label>
                                <input class="text-input small-input" type="text" id="small-input" name="title_ar" />
                            </p>

                            <p>
                                <label><?= product_title_en ?></label>
                                <input class="text-input small-input" type="text" id="small-input" name="title_en" />
                            </p>

                            <p>
                                <label><?= product_desc_ar ?></label>
                                <textarea class="text-input textarea wysiwyg" id="textarea" name="desc_ar" cols="79" rows="15"></textarea>
                            </p>

                            <p>
                                <label><?= product_desc_en ?></label>
                                <textarea class="text-input textarea wysiwyg" id="textarea" name="desc_en" cols="79" rows="15"></textarea>
                            </p>

                            <p>
                                <label><?= product_image ?></label>
                                <input type="file" name="image" class="small-input"/>
                            </p>
                            <p>
                                <label><?= price ?></label>
                               $  <input style ="width: 50px !important; " class="text-input small-input" type="text" id="small-input" name="price" />
                            </p>


                            <p>
                                <label><?= product_status ?></label>
                                <input type="radio" name="status" value = "active" /><?= Active ?><br />
                                <input type="radio" name="status" value = "deactive" /><?= Deactive ?>
                            </p>

                            <p>
                                <label><?= product_cat ?></label>
                                <select name="cat" class="small-input">
                                    <option value="1"><?= Nokia ?></option>
                                    <option value="2"><?= Samsung ?></option>
                                    <option value="3"><?= Motorola ?></option>
                                    <option value="4"><?= SonyEricsson ?></option>
                                    <option value="5"><?= LG ?></option>
                                    <option value="6"><?= Apple ?></option>
                                    <option value="7"><?= BlackBerry ?></option>
                                   
                                </select>
                            </p>
                             <p>
                                <label><?= type ?></label>
                                <select name="type" class="small-input">
                                    <option value="1"><?= General?></option>
                                    <option value="2"><?= Special  ?></option>
                                </select>
                             </p>
                            <p>
                                <input class="button" type="submit" name = "addproduct" value="<?= Add_Product ?>" />
                            </p>

                        </fieldset>

                        <div class="clear"></div>

                    </form>

                </div>
            </div>
        </div>
    </div>
</div>